﻿using MongoDB.Driver;
using Sustainalytics.Entities;
using System.Threading.Tasks;

namespace Sustainalytics.Governance.Synchronization
{
    public class CorporateGovernanceIndexes
    {
        public static async Task RecreateIndexes(IMongoCollection<GovernanceSource> collection)
        {
            await collection.Indexes.CreateOneAsync(Builders<GovernanceSource>.IndexKeys.Ascending(x => x.CompanyId).Ascending(x => x.Text)).ConfigureAwait(false);
        }

        public static async Task RecreateIndexes(IMongoCollection<GovernanceIndicator> collection)
        {
            await collection.Indexes.CreateOneAsync(Builders<GovernanceIndicator>.IndexKeys.Ascending(x => x.CompanyId)).ConfigureAwait(false);
        }

        public static async Task RecreateIndexes(IMongoCollection<GovernanceIssue> collection)
        {
            await collection.Indexes.CreateOneAsync(Builders<GovernanceIssue>.IndexKeys.Ascending(x => x.CompanyId)).ConfigureAwait(false);
        }
    }
}
